﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Regnemaskinen
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack) { 
                string todo = operation.SelectedValue.ToString();
                decimal firstValue = Convert.ToDecimal(text1.Text);
                decimal secontValue = Convert.ToDecimal(text2.Text);
                decimal res = 0;
                switch (todo)
                {
                    case "+":
                        res = firstValue + secontValue;
                        result.InnerText = res.ToString();
                        break;
                    case "-":
                        res = firstValue - secontValue;
                        result.InnerText = res.ToString();
                        break;
                    case "*":
                        res = firstValue * secontValue;
                        result.InnerText = res.ToString();
                        break;
                    case "/":
                        if (firstValue != 0 && secontValue != 0)
                        {
                            res = firstValue / secontValue;
                        }
                        else
                        {
                            res = 0;
                        }
                        result.InnerText = res.ToString();
                        break;
                }
            }
        }
    }
}